package com.jbp.controller;

import com.jbp.redis.RedisConfigService;
import com.jbp.service.EventService;
import com.jbp.service.LotteryService;
import com.jbp.utils.R;
import com.qiniu.util.Json;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 活动接口
 */
@Api(tags ="APP接口--活动" ,hidden = true)
@ApiIgnore
@RestController
@RequestMapping("event")
public class EventController {
    @Autowired
    private EventService eventService;
    @Autowired
    private LotteryService lotteryService;
    @Autowired
    private RedisConfigService redisConfigService;

    @Value("${runType}")
    private String runType;
    @Value("${xiaohao.namePrex}")
    private String namePrex;
    @Value("${xiaohao.open}")
    private boolean xiaohaoOpen;

    @GetMapping("/heart")
    public int heart(){
        return 1;
    }

    @GetMapping("/config")
    public R config(){
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("runType", runType);
        map.put("xiaohaoOpen", xiaohaoOpen);
        map.put("namePrex", namePrex);
        map.put("currentTime", new Date());
        return R.ok(map);
    }

    @GetMapping("/newUsers")
    public String newUsers(){
        String key = "user:new:cache";
        return (String) redisConfigService.lget(key);
    }

    /**
     * 哈哈牛活动1
     * */
    @GetMapping("/getHahaniu1")
    public R getHahaniu1(){
        return R.ok(eventService.getHahaniu1());
    }
    /**
     * 哈哈牛活动1
     * */
    @GetMapping("/getHahaniu2")
    public R getHahaniu2(){
        return R.ok(eventService.getHahaniu2());
    }
    /**
     * 闹闹活动1
     * */
    @GetMapping("/getNaonao1")
    public R getNaonao1(){
        return R.ok(eventService.getNaonao1());
    }
    /**
     * 咚咚熊活动1
     * */
    @GetMapping("/getDongdongxiong1")
    public R getDongdongxiong1(){
        return R.ok(eventService.getDongdongxiong1());
    } /**
     * 咚咚熊活动1
     * */
    @GetMapping("/getDongdongxiong2")
    public R getDongdongxiong2(){
        return R.ok(eventService.getDongdongxiong2());
    }
    /**
     * 聊天室联盟活动
     * */
    @GetMapping("/lianMeng")
    public R lianMeng(){
        return R.ok(eventService.getLianMeng());
    }


    /**
     * 贡献榜活动
     * */
    @GetMapping("/contribution")
    public R contribution(){
        return R.ok(eventService.contribution());
    }

    /**
     * 秋季鱼卡活动
     * */
    @GetMapping("/yuka")
    public R yuka(){
        return R.ok(eventService.yuka());
    }
    /**
     * 海鸥活动
     * */
    @GetMapping("/haiOu")
    public R haiOu(){
        return R.ok(eventService.haiou());
    }


    /**11月13日活动  三天贡献榜总榜 20名*/
    @GetMapping("/hd5")
    public R hd5(){
        return R.ok(eventService.hd5());
    }

    /**绿毛龟当日中间数量*/
    @GetMapping("/gui1")
    public R gui1(@RequestParam("userId") Integer uid, @RequestParam("giftId") Integer giftId){
        return R.ok().put("data", lotteryService.todayCount(uid, giftId));
    }
}